

<title>当前借阅</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>图书馆</cite></a>
        <a><cite>当前借阅</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">当前借阅</div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="test-table-page" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="lineBar">
    <a class="layui-btn layui-btn-xs" lay-event="relend">续借</a>
</script>


<script>
    layui.use(['jquery', 'table'], function() {
        var $ = layui.$, form = layui.form, table = layui.table;
        var relendUrl = "/uclass/library/relend";

        var tablelns = table.render({
            elem: '#test-table-page'
            , url: "/uclass/library/lendlist"
            , toolbar: '#toolbarlist'
            , cols: [[
                {field: 'mTitle', minWidth:150, title: '书名', align: 'center'}
                , {field: 'normRetDate', minWidth: 120, title: '应还日期', align: 'center'}
                , {field: 'renewTimes', title:'续借次数'}
                , {align: 'center', title: '操作', toolbar: '#lineBar'}
            ]]
            , parseData: function (res) {
                return {
                    "status": res.status,
                    "message": res.message,
                    "list": res.data
                };
            }
            , response: {
                statusName: 'status'
                , statusCode: 200
                , msgName: 'message'
                , dataName: 'list'
            }
        });
        table.on('tool(test)', function (obj) {
            switch (obj.event) {
                case 'relend':
                    var load = layer.load(2);
                    $.ajax({
                        async: false,
                        url: relendUrl,
                        type: 'POST',
                        dataType: 'json',
                        data: "barCode=" + obj.data.barCode,
                        complete: function(result) {
                            layer.close(load);
                            layer.msg(result.responseJSON.data.msg, function () {
                                layui.index.render();
                            });
                        }
                    });
                    break;
            }
        })
    });
</script>